import 'package:flutter/material.dart';
import 'package:flutter01/plugins/chewie.dart';
import 'package:flutter01/plugins/connectivity.dart';
import 'package:flutter01/plugins/image_picker.dart';
import 'package:flutter01/plugins/more.dart';
import 'package:flutter01/plugins/shared_preferences.dart';
import 'package:flutter01/plugins/url_launch.dart';
import 'package:flutter01/plugins/webview.dart';
import 'barcodeScan.dart';
import 'http.dart';
import 'dio.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        theme: ThemeData(
          useMaterial3: false,
          primarySwatch: Colors.blue,
        ),
        home: Scaffold(
          appBar: AppBar(
            title: const Text("Flutter App"),
          ),
          body: const MyHome()
        ),
      routes: {
          "/http" :(context) => const HttpPage(),
          "/dio" :(context) => const DioPage(),
          "/more" :(context) => const MorePage(),
          "/webview" :(context) => const WebViewPage(),
          "/imagePicker" :(context) => const ImagePickerPage(),
          "/chewie" :(context) => const ChewiePage(),
          "/connectivity" :(context) => const ConnectivityPage(),
          "/barcodeScan" :(context) => const BarcodeScanPage(),
          "/urlLaunch" :(context) => const UrlLaunchPage(),
          "/shared" :(context) => const SharedPreferencesPage(),
      },
    );
  }
}


class MyHome extends StatelessWidget {
  const MyHome({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          ElevatedButton(onPressed: (){
            Navigator.pushNamed(context, "/http");
          }, child: const Text("Http插件")),
          ElevatedButton(onPressed: (){
            Navigator.pushNamed(context, "/dio");
          }, child: const Text("Dio插件")),
          ElevatedButton(onPressed: (){
            Navigator.pushNamed(context, "/more");
          }, child: const Text("下拉刷新以及上拉加载更多")),
          ElevatedButton(onPressed: (){
            Navigator.pushNamed(context, "/webview");
          }, child: const Text("webview插件")),
          ElevatedButton(onPressed: (){
            Navigator.pushNamed(context, "/imagePicker");
          }, child: const Text("Native调用相机")),
          ElevatedButton(onPressed: (){
            Navigator.pushNamed(context, "/chewie");
          }, child: const Text("chewie播放视频")),
          ElevatedButton(onPressed: (){
            Navigator.pushNamed(context, "/connectivity");
          }, child: const Text("connectivity检测网络状态")),
          ElevatedButton(onPressed: (){
            Navigator.pushNamed(context, "/barcodeScan");
          }, child: const Text("flutter_barcode_scanner扫描二维码")),
          ElevatedButton(onPressed: (){
            Navigator.pushNamed(context, "/urlLaunch");
          }, child: const Text("url_launch调起第三方模块")),
          ElevatedButton(onPressed: (){
            Navigator.pushNamed(context, "/shared");
          }, child: const Text("shared_preferences本地存储")),
        ],
      ),
    );
  }
}



